<template>
	<view class="container">
		<!-- 卡片容器 -->
		<view class="card">
			<!-- 标题 -->
			<view class="title-section">
				<text class="title">归还驳回信息</text>
			</view>
			<view class="info-item">
				<text class="info-label">物流公司</text>
				<text class="info-content">{{return_express_name}}</text>
			</view>
			<!-- 物流单号 -->
			<view class="info-item">
				<text class="info-label">物流单号</text>
				<text class="info-content">{{return_express_no}}</text>
			</view>

			<!-- 拒绝原因 -->
			<view class="info-item">
				<text class="info-label">拒绝原因</text>
				<text class="info-content">{{refuse_reason}}</text>
			</view>

			<!-- 图片展示 -->
			<view class="info-item">
				<text class="info-label">问题凭证</text>
				<view class="image-grid">
					<image v-for="(img, index) in refuse_pics" :key="index" :src="img" class="preview-image"
						@click="previewImage(img)" mode="aspectFill" />

				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				refuse_pics: [],
				refuse_reason: '',
				return_express_no: '',
				return_express_name: '',
				order_id: ''
			};
		},
		onLoad(e) {
			this.order_id = e.order_id;
		},
		onShow() {
			uni.showLoading({
				title: '加载中'
			});
			/*获取订单详情*/
			this.getData();
		},
		mounted() {
			uni.showLoading({
				title: '加载中'
			});
			/*获取订单详情*/
			this.getData();
		},
		methods: {
			previewImage(url) {
				console.log(url)
				uni.previewImage({
					current: this.refuse_pics.findIndex(item => item), // 找到当前点击图片的索引  
					urls: this.refuse_pics.map(item => item), // 提取所有图片的url  
				});
			},
			/*获取数据*/
			getData() {
				let self = this;
				let order_id = self.order_id;
				let url = 'user.order/orderReturned';
				self._get(url, {
						order_id: order_id,
					},
					function(res) {
						console.log(res)
						self.refuse_pics = res.data.refuse_pics.split(',')
						self.refuse_reason = res.data.refuse_reason
						self.return_express_no = res.data.return_express_no
						self.return_express_name = res.data.return_express_name
						uni.hideLoading();
					}
				);
			},

		}
	};
</script>

<style lang="scss">
	.container {
		padding: 20rpx;
		background-color: #f5f5f5;
		min-height: 100vh;
	}

	.card {
		background-color: #ffffff;
		border-radius: 16rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.title-section {
		margin-bottom: 30rpx;
		position: relative;
	}

	.title {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
		display: block;
		margin-bottom: 20rpx;
	}

	.divider {
		height: 4rpx;
		width: 80rpx;
		background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
		border-radius: 2rpx;
	}

	.info-item {
		margin-bottom: 40rpx;
	}

	.info-label {
		font-size: 28rpx;
		color: #999;
		display: block;
		margin-bottom: 10rpx;
	}

	.info-content {
		font-size: 32rpx;
		color: #333;
		font-weight: 500;
	}

	.image-grid {
		display: flex;
		flex-wrap: wrap;
		margin: -5rpx;
	}

	.preview-image {
		width: calc(33.333% - 10rpx);
		height: 200rpx;
		margin: 5rpx;
		border-radius: 8rpx;
		box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1);
	}
</style>